package xyz.thoughtset.viewer.common.ai.model.utils;

import lombok.NonNull;
import lombok.experimental.UtilityClass;
import org.springframework.util.ObjectUtils;
import xyz.thoughtset.viewer.common.ai.model.entity.ModelParam;

import java.util.Map;
import java.util.function.Consumer;

@UtilityClass
public class ModelBuilderHelper {

//    ModelBuilderHelper.setIfNotNull(modelParam, "topP", builder::topP);
    public static <T> void setIfNotNull(ModelParam modelParam, String key, Consumer<T> setter) {
        Map <?, ?> map = modelParam.getParamMap();
        setIfNotNull(map, key, setter);
    }
    public static <T> void setIfNotNull(@NonNull Map <?, ?> map, String key, Consumer<T> setter) {
        T value = (T) map.get(key);
        if (value != null) {
            setter.accept(value);
        }
    }
}
